/*
 * @Descripttion:
 * @version:
 * @Author: liyuhang
 * @Date: 2022-05-19 10:27:55
 */

Vue.component("search-page", {
  template: '\
      <div class="search_wrapper" style="height: 100%; display: flex;flex-direction: column;">\
        <div class="bgcDiv1">\
          <form class="form_box" action="javascript:void 0;">\
            <van-search style="flex:1" id="out_box" ref="search" shape="round" v-model="value1" placeholder="输入你想查找的内容" @Keyup.13 = "onSearch"/>\
            <div class="form_btn"><van-button class="form_btn_wrapper" type="primary" @click="onSearch">搜索</van-button></div>\
          </form>\
        </div>\
        <div class="current">\
          <van-tabs v-model="active1" @change="onClick">\
          <van-tab title="新闻资讯">\
          <van-list v-model="newloading" :finished="newFinished" finished-text="没有更多了" @load="getNewList(0)">\
            <van-cell v-for="(item , index) in newList" :key="index">\
            <div class="wrapper_content">\
            <a v-if="showURl" :href="item._source.url">{{ item._source.title | textNum }}</a>\
            <p @click="checkCon(item)" class="box-card_title"> {{ item._source.title | textNum}}</p>\
            <p class="content_list">{{item._source.content | textNum}}</p>\
            <div class="List_time">\
            <span class="List_name">{{item._source.city}}</span> <span class="lines_c"></span><span class="List_name">{{ item._source.publictime }}</span>\
                      </div>\
            </div>\
            <div class="omit" @click="confirmSend(item)">\
                    <div class="omit_box" style="width: 25px;height: 25px;">\
                    <img src="../image/fayou.png" alt="">\
                    </div>\
        </div>\
            </van-cell>\
          </van-list>\
        </van-tab>\
            <van-tab title="我的文档">\
              <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getList()">\
                <van-cell v-for="item in list" :key="item.id">\
                <div class="wrapper_content">\
                <div class="img_box">\
                <img v-if=\'item.documentType == "Word"\' src="../image/newDocument.png" alt="">\
                <img v-if=\'item.documentType == "Excel"\' src="../image/newDocument1.png" alt="">\
                <img v-if=\'item.documentType == "TXT"\' src="../image/newDocument4.png" alt="">\
                <img v-if=\'item.documentType == "PPT"\' src="../image/newDocument2.png" alt="">\
                <img v-if=\'item.documentType == "PDF"\' src="../image/newDocument3.png" alt="">\
                <img v-if=\'item.documentType == "WPS"\' src="../image/wps.png" alt="">\
              </div>\
              <div class="text_h">\
                    <div class="List_title">{{ item.documentName }}</div>\
                    <p class="content_list">{{item.content | textNum}}</p>\
                    <div class="List_time">\
                    <span class="List_name">{{item.createTime}}</span><span class="lines_c"></span><span class="List_name">{{ item.fileSize }}</span>\
                              </div>\
              </div>\
                </div>\
                <div class="omit">\
                <el-dropdown @command="handleCommand($event,item)" trigger="click">\
                    <span class="el-dropdown-link">\
                        <div class="omit_box">\
                        <img src="../image/dian.png" alt="">\
                        </div>\
                    </span>\
                    <el-dropdown-menu slot="dropdown">\
                        <el-dropdown-item command="a">重命名</el-dropdown-item>\
                        <el-dropdown-item  v-if=\'item.documentType != "PDF"\' command="b" >编辑</el-dropdown-item>\
                        <el-dropdown-item command="c">删除</el-dropdown-item>\
                        <el-dropdown-item v-if=\'item.documentType != "PPT"\' command="d">分享</el-dropdown-item>\
                        <el-dropdown-item v-if=\'item.documentType == "PDF"\' command="g">发送邮箱</el-dropdown-item>\
                        <el-dropdown-item v-if=\'item.documentType != "TXT"\' command="e">水印</el-dropdown-item>\
                    </el-dropdown-menu>\
                </el-dropdown>\
            </div>\
                </van-cell>\
              </van-list>\
            </van-tab>\
            <van-popup round :close-on-click-overlay="popstate" :close="closePopstate" v-model="nameListShow" closeable style="width:80%;max-height: 50%;padding:10px 10px 20px;">\
              <div class="title" style="height: 50px;overflow: hidden;display: flex;justify-content: center;">\
                  <span>分享人列表</span>\
              </div>\
              <div class="tabulation" id="nameBox">\
                  <van-radio-group  v-model="radio" @change="checkRadio">\
                    <van-list v-model="shareloading" :finished="shareFinished" finished-text="没有更多了" @load="getShareList()">\
                        <van-cell v-for="item in nameList">\
                            <div class="wrpperName">\
                                    <div class="Name_title" style="left: 9%;">\
                                  <van-radio :name="item.userId">{{item.name}} <span style="font-weight:normal;">{{ item.unitName }}</span> </van-radio>\
                                    </div>\
                            </div>\
                        </van-cell>\
                    </van-list>\
                  </van-radio-group>\
              </div>\
              <div class="enjoyName"><span style="margin-right:10px;font-size:12px;font-weight: bolder;">多人编辑</span><van-switch size="15px" style="margin-right: 15%;margin-top: 2px;" v-model="checkedEdit" @click="changeSwitch" /><van-button round style="margin-right:5%;border:0;width:20%;height:25px;font-weight: bolder;" size="small" @click="shareCancel">取消</van-button><van-button round style="border:0;width:20%;height:25px;margin-right: 5%;" type="info" size="small" @click="getShare">确定</van-button></div>\
            </van-popup>\
            <van-tab title="共享文档">\
              <van-list v-model="ehjoyLoading" :finished="ehjoyFinished" finished-text="没有更多了" @load="getEhjoyList()">\
                <van-cell v-for="item in ehjoyList" :key="item.id">\
                    <div class="wrpper">\
                        <div class="img_box">\
                          <img v-if=\'item.documentType == "Word"\' src="../image/newDocument.png" alt="">\
                          <img v-if=\'item.documentType == "Excel"\' src="../image/newDocument1.png" alt="">\
                          <img v-if=\'item.documentType == "TXT"\' src="../image/newDocument4.png" alt="">\
                          <img v-if=\'item.documentType == "PPT"\' src="../image/newDocument2.png" alt="">\
                          <img v-if=\'item.documentType == "PDF"\' src="../image/newDocument3.png" alt="">\
                          <img v-if=\'item.documentType == "WPS"\' src="../image/wps.png" alt="">\
                        </div>\
                        <div class="text_h">\
                            <div class="List_title">{{ item.documentName }}</div>\
                            <div class="List_wrapper">\
                                <div class="List_time"><span>{{item.createTime}}</span><span class="lines">𐊊</span></div>\
                                <div class="List_access">{{ item.fileSize }}</div>\
                            </div>\
                        </div>\
                        <div class="omit">\
                            <el-dropdown @command="handleCommand($event,item)" trigger="click">\
                                <span class="el-dropdown-link">\
                                    <div class="omit_box">\
                                    <img src="../image/dian.png" alt="">\
                                    </div>\
                                </span>\
                                <el-dropdown-menu slot="dropdown">\
                                    <el-dropdown-item command="a">重命名</el-dropdown-item>\
                                    <el-dropdown-item v-if=\'item.documentType == "PDF"\' command="g">发送邮箱</el-dropdown-item>\
                                    <el-dropdown-item v-if=\'item.documentType != "PDF"\'  command="b">编辑</el-dropdown-item>\
                                    <el-dropdown-item command="f">删除</el-dropdown-item>\
                                </el-dropdown-menu>\
                            </el-dropdown>\
                        </div>\
                    </div>\
                </van-cell>\
              </van-list>\
            </van-tab>\
          </van-tabs>\
        </div>\
        <div>\
          <van-dialog v-model="show" title="重命名" show-cancel-button @confirm="confirm" @cancel="cancel">\
            <div class="nameList">\
              <span>文件名：</span>\
              <input v-model="updateName" maxLength="50" type="text" @input="handleInput">\
              <span>{{ suffix }}</span>\
            </div>\
          </van-dialog>\
        </div>\
        <div>\
          <van-dialog v-model="cheakShow" title="" show-cancel-button :show-confirm-button="false"  @cancel="conCancel">\
            <div class="conList">\
              <p class="showTit">{{ conDetail.title}}</p>\
              <p class="showTime"><span style="margin-right:10px;">{{conDetail.city}}</span> {{conDetail.publictime}}</p>\
              <textarea readonly class="showCon" v-model="conDetail.content"></textarea>\
            </div>\
          </van-dialog>\
        </div>\
        <div>\
          <van-dialog v-model="syNameShow" title="添加水印" show-cancel-button @confirm="syConfirm" @cancel="cancel">\
            <div class="nameList">\
              <span>水印名称：</span>\
              <input maxLength="20" v-model="syName" type="text" @input="handleInput">\
            </div>\
          </van-dialog>\
        </div>\
        </div>\
        ',
  data() {
    return {
      showURl:false,
      sharePeopleId:'', //分享人的userId
      active1: 0,
      radio:1,
      popstate:false,
      checkedEdit:false,
      nameListShow:false,
      syNameShow:false,
      nameList:[],
      value1: '',
      newList: [],

      list: [],
      ehjoyList: [],
      // 弹出层
      show: false,
      value: 1,
      loading: false,
      newloading: false,
      shareloading: false,
      ehjoyLoading: false,
      newFinished: false,
      ehjoyFinished: false,
      shareFinished: false,
      finished: false,
      num: 0,
      newNum: 0,
      ehjoyNum: 0,
      shareNum: 0,
      total: 0,
      shareTotal: 0,
      newTotal: 0,
      ehjoyTotal: 0,
      // 重命名
      updateName: '',
      // 水印名称
      syName: '',
      id: '',
      suffix: '',
      cheakShow:false,
      conDetail:{},
    };
  },
  filters: {
    textNum: (value) => {
      if (!value) return "";
      let data = value.split("");
      if (data.length < 15) {
        return value;
      }
      return value.slice(0, 15) + "...";
    },
  },
  created() {
    this.$nextTick(() => {
      this.getNewList()  // open
    });
  },
  mounted() {
      if (sessionStorage.getItem("iscp_port")) {
        iscp_port = sessionStorage.getItem("iscp_port");
      } else {
        iscp_port = "";
      }
    this.getList(0, '')
    if (this.searchValue == true) {
      // this.$nextTick(() => {
      //   this.$refs.search.focus();
      // });
      document.getElementById("out_box").focus();
    }
  },
  props: ['searchValue'],
  methods: {
    conCancel(){
      this.cheakShow = false
      this.conDetail = {}
    },
    checkCon(con) {
      this.conDetail = con._source
   this.cheakShow= true
    },
    confirmSend(item,num) {
      var btnArray = ["取消", "确定"];
      var i = 0;
      mui.confirm("请问是否发送内网邮箱？", "消息提醒", btnArray, (e) => {
        if (i > 0) return;
        i++;
        if (e.index == 1) {
          this.omitBtn(item._source ? item._source : '' ,num)
        }
      });
    },
    // 新闻发邮箱
    omitBtn(item,num){
      console.log(item,num)
      $(".curtain").css("display", "block");
      let timestamp = new Date().getTime() + "";
      let data = {
        timestamp: timestamp,
        userId: userId,
        title: "AI助手-" + item.title ? item.title : '',
        content:item.content ? item.content : '',
        sceneNo: num == 1 ? 54 : 55,
        id:this.id
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/email/sendMail',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              sessionStorage.setItem("Authentication", Authentication);
              mui.toast('已发送到内网邮箱', {
                duration: 1000,
                type: 'div'
              })
            }else{
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error:() => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        }
      })
    },
    checkRadio(item) {
      this.sharePeopleId = item;
      console.log(item)
    },
    //tab切换
    onClick(val) {
      this.value1 = ''
      this.changeDate(val)
    },
    changeDate(count) {
      this.list = []
      this.newList = []
      this.ehjoyList = []
      this.num = 0
      this.newNum = 0
      this.ehjoyNum = 0
      this.active1 = count
      if (count == 1) {
        this.resstFileList()
      }else if(count == 2) {
        this.getEhjoyList()
      } else {
        this.getNewList()
      }
    },
    hyperLink(url) {
      this.$shell.openPath(url);
    },
    // 分享人列表
    getShareList() {
      let userId = sessionStorage.getItem("userId");
      this.shareNum += 1
      let timestamp = new Date().getTime() + "";
      let data = {
        userId:userId,
        timestamp: timestamp,
        pageNum: this.shareNum,
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/share/getShareUsers',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          console.log(res, "res")
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              console.log(Authentication, 'Authentication')
              sessionStorage.setItem("Authentication", Authentication);
              this.shareTotal = res.resultValue.total
              this.nameList = res.resultValue.list
              if (this.shareTotal == 0) {
                this.shareFinished = true;
              }
              if (res.resultValue.list.length < 10) {
                this.shareFinished = true;
              }
              if (this.shareNum == 1) {
                this.nameList = []
              }
              res.resultValue.list.forEach((item) => {
                this.nameList.push(item)
              })
              // 加载状态结束
              this.shareloading = false;
              if (this.nameList.length >= res.resultValue.total) {
                this.shareFinished = true;
              }
            } else {
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    shareCancel(){
      this.nameListShow = false
    },
    changeSwitch(){
      console.log(this.checkedEdit,"开关的值");
    },
    // 分享功能
    getShare() {
      let timestamp = new Date().getTime() + "";
      let userId = sessionStorage.getItem("userId");
      let data = {
        timestamp: timestamp,
        userId: userId,
        id:this.id,
        userIds:this.sharePeopleId,
        editing:this.checkedEdit?'1':'0',
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/share/shared',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          console.log(res, "res")
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              sessionStorage.setItem("Authentication", Authentication);
              mui.toast("分享成功", {
                duration: 1000,
                type: 'div'
              })
              this.nameListShow = false
            } else {
              mui.toast("分享失败", {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    // 文件列表
    getList() {
      this.num += 1
      let userId = sessionStorage.getItem("userId");
      let timestamp = new Date().getTime() + "";
      let data = {
        timestamp: timestamp,
        userId: userId,
        content:this.value1,
        pageNum: this.num,
        type: '',
        suffix: '',
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/record/getDocumentList',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          console.log(res, "res")
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              console.log(Authentication, 'Authentication')
              if (Authentication) {
              sessionStorage.setItem("Authentication", Authentication);
              this.total = res.resultValue.total
              if (this.total == 0) {
                this.finished = true;
              }
              if (res.resultValue.list.length < 10) {
                this.finished = true;
              }
              // if (this.num == 1) {
              //   console.log(214, this.num)
              //   this.list = []
              // }
              res.resultValue.list.forEach((item) => {
                this.list.push(item)
              })
              // 加载状态结束
              this.loading = false;
              if (this.list.length >= res.resultValue.total) {
                this.finished = true;
              }
            } else {
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            }
          }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    // 分享文件列表
    getEhjoyList() {
      this.ehjoyNum += 1
      let userId = sessionStorage.getItem("userId");
      let timestamp = new Date().getTime() + "";
      let data = {
        timestamp: timestamp,
        userId: userId,
        condition:this.value1,
        pageNum: this.ehjoyNum,
        type: '',
        suffix: '',
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/share/getSharedDocument',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              console.log(Authentication, 'Authentication')
              if (Authentication) {
              sessionStorage.setItem("Authentication", Authentication);
              this.ehjoyTotal = res.resultValue.total
              if (this.ehjoyTotal == 0) {
                this.ehjoyFinished = true;
              }
              if (res.resultValue.list.length < 10) {
                this.ehjoyFinished = true;
              }
              if (this.ehjoyNum == 1) {
                this.ehjoyList = []
              }
              res.resultValue.list.forEach((item) => {
                this.ehjoyList.push(item)
              })
              // 加载状态结束
              this.ehjoyLoading = false;
              if (this.ehjoyList.length >= res.resultValue.total) {
                this.ehjoyFinished = true;
              }
            } else {
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            }
          }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    // 新闻接口
    getNewList() {
      this.newNum += 1
      let userId = sessionStorage.getItem("userId");
      let timestamp = new Date().getTime() + "";
      let data = {
        start: this.newNum,
        searchTitle: '',
        searchContent: '',
        // startDate: this.search.startDate,
        // endDate: this.search.endDate,
        timestamp: timestamp,
        userId: userId,
        q: this.value1 =='' ? '电网' : this.value1,
        docType:"tjnews",
        size: 20,
      };
      console.log(data, 200);
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/news/search_test',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          console.log(res, "res")
          $(".curtain").css("display", "none");
          console.log(888)
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              if (Authentication) {
              sessionStorage.setItem("Authentication", Authentication);
              this.newTotal = res.resultValue.total
              if (this.newTotal == 0) {
                this.newFinished = true;
              }
              if (res.resultValue.data.length < 10) {
                this.newFinished = true;
              }
              if (this.newNum == 1) {
                this.newList = []
              }
              res.resultValue.data.forEach((item) => {
                this.newList.push(item)
              })
              // 加载状态结束
              this.newloading = false;
              if (this.newList.length >= res.resultValue.total) {
                this.newFinished = true;
              }
            } else { 
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            }
          }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    handleCommand(a, b) {
      console.log(a,b,'22222222222')
      this.id = ''
      this.updateName = ''
      this.suffix = ''
      this.id = b.id
      const c = b.documentName.split('.')
      this.updateName = c[0]
      this.suffix = b.documentSuffix
      if (a == 'a') {
        this.show = true
      } else if (a == 'b') {
        this.editDocument(this.id)
      }  else if (a == 'd') {
        this.nameListShow = true
        this.shareNum = 0
        this.nameList = []
        this.shareFinished = false,
        this.shareTotal = 0
        this.shareloading = false;
        this.getShareList()
      } else if (a == 'e') {
        this.syNameShow = true
      } else if (a == 'g') {
        this.confirmSend('',1)
      } else {
        var btnArray = ["取消", "确定"];
        var i = 0;
        mui.confirm("请问是否确定删除？", "消息提醒", btnArray, (e) => {
          if (i > 0) return;
          i++;
          if (e.index == 1) {
            this.documentDelete(this.id,a)
          }
        });
      }
    },
    // 搜索
    onSearch() {
      if (this.active1 == 0) {
        this.changeDate(0)
      } else {
        this.changeDate(1)
      }
    },
    // onSearch() {
    //   
    //   if (sessionStorage.getItem("iscp_port")) {
    //     iscp_port = sessionStorage.getItem("iscp_port");
    //   } else {
    //     iscp_port = "";
    //   }
    //   let timestamp = new Date().getTime() + "";
    //   let data = {
    //     timestamp: timestamp,
    //     userId: userId,
    //     documentName: this.value1,
    //     pageNum: 1,
    //   };
    //   console.log(data, 200);
    //   data = JSON.stringify(data);
    //   let sign = sm3(data);
    //   let AuthenticationSession = sessionStorage.getItem("Authentication");
    //   let URL = ''
    //   $.ajax({
    //     url: localUrlLink + iscp_port + '/document/record/documentSearch',
    //     type: "post",
    //     async: false, //是否同步，false表示同步请求
    //     dataType: "json",
    //     data: data,
    //     contentType: 'application/json',
    //     headers: {
    //       Authentication: AuthenticationSession,
    //       sign: sign,
    //       timestamp: timestamp
    //     },
    //     success: (res, txt, xhr) => {
    //       console.log(res, "res搜索")
    //       $(".curtain").css("display", "none");
    //       if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
    //         let Authentication = xhr.getResponseHeader("Authentication")
    //         if (res.code == 200) {
    //           this.list = []
    //           console.log(res.resultValue.total,322);
    //           this.total = res.resultValue.total
    //           if (this.total == 0) {
    //             this.finished = true;
    //           }
    //           if (res.resultValue.list.length < 10) {
    //             this.finished = true;
    //           }
    //           res.resultValue.list.forEach((item) => {
    //             this.list.push(item)
    //           })
    //           if (this.list.length >= res.resultValue.total) {
    //             this.finished = true;
    //           }
    //           console.log(this.list, 328);
    //         } else {
    //           mui.toast(res.resultValue, {
    //             duration: 1000,
    //             type: 'div'
    //           })
    //         } 
    //       } else {
    //         mui.toast('完整性校验失败', {
    //           duration: 1000,
    //           type: 'div'
    //         })
    //       }
    //     },
    //     error: (e) => {
    //       $(".curtain").css("display", "none");
    //       mui.toast('请求异常,请稍后再试', {
    //         duration: 1000,
    //         type: 'div'
    //       })
    //     },
    //   });
    // },
    // 关闭分享人的弹出层
    closePopstate(){
        this.checkedEdit = false
        this.nameListShow = false
    },
    //确定
    confirm() {
      this.num += 1
      let timestamp = new Date().getTime() + "";
      let data = {
        timestamp: timestamp,
        id: this.id,
        updateName: this.updateName,
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      let URL = ''
      $.ajax({
        url: localUrlLink + iscp_port + '/document/record/documentUpdate',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              sessionStorage.setItem("Authentication", Authentication);
              mui.toast('修改成功', {
                duration: 1000,
                type: 'div'
              })
              this.resstFileList()
            } else {
              mui.toast('修改失败', {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    //确定
    syConfirm() {
      // this.num += 1
      let userId = sessionStorage.getItem("userId");
      let timestamp = new Date().getTime() + "";
      let data = {
        userId:userId,
        timestamp: timestamp,
        id: this.id,
        content: this.syName,
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      let URL = ''
      $.ajax({
        url: localUrlLink + iscp_port + '/document/transform/documentWatermark',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          console.log(res, "res")
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              sessionStorage.setItem("Authentication", Authentication);
              mui.toast('添加水印成功', {
                duration: 1000,
                type: 'div'
              })
              this.syName = ''
              this.resstFileList()
            } else {
              mui.toast('添加水印失败', {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    // 取消
    cancel() {
      this.show = false
      this.syNameShow = false
      this.updateName = ''
      this.syName = ''
    },
    // input限制输入
    handleInput() {
      // 过滤特殊字符、空格和表情包
      // this.updateName = this.updateName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '');
      // 过滤特殊字符和表情包
      this.updateName = this.updateName.replace(/[\\/:*?"<>|？“”：*]/g, '');
      this.syName = this.syName.replace(/[\\/:*?"<>|？“”：*]/g, '');
    },
    // 删除
    documentDelete(id,name) {
      let userId = sessionStorage.getItem("userId");
      let timestamp = new Date().getTime() + "";
      let data = {
        timestamp: timestamp,
        userId: userId,
        id: id
      };
      console.log(data, 200);
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      $.ajax({
        url: localUrlLink + iscp_port + '/document/record/documentDelete',
        type: "post",
        async: false, //是否同步，false表示同步请求
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              sessionStorage.setItem("Authentication", Authentication);
              mui.toast('删除成功', {
                duration: 1000,
                type: 'div'
              })
             this.resstFileList(name)
            } else if (res.code == 500) {
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            } else {
              mui.toast('失败', {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
    // 重置文件列表
    resstFileList(name) {
      this.num = 0
      this.ehjoyNum = 0
      this.total = 0
      this.ehjoyTotal
      this.list = []
      this.ehjoyList = []
      this.ehjoyFinished = false
      this.finished = false
      this.loading = false
      this.ehjoyLoading = false
      if(name == 'f') {
        this.getEhjoyList()
      } else {
        this.getList()

      }
   
    },
    //编辑
    editDocument(id) {
      let userId = sessionStorage.getItem("userId");
      let timestamp = new Date().getTime() + "";
      let data = {
        timestamp: timestamp,
        userId: userId,
        id: id
      };
      data = JSON.stringify(data);
      let sign = sm3(data);
      let AuthenticationSession = sessionStorage.getItem("Authentication");
      let URL = ''
      $.ajax({
        url: localUrlLink + iscp_port + '/document/transform/editDocument',
        type: "post",
        async: false, //是否同步，false表示同步请求1`2
        dataType: "json",
        data: data,
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          Authentication: AuthenticationSession,
          sign: sign,
          timestamp: timestamp
        },
        success: (res, txt, xhr) => {
          $(".curtain").css("display", "none");
          if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
            let Authentication = xhr.getResponseHeader("Authentication")
            if (res.code == 200) {
              sessionStorage.setItem("Authentication", Authentication);
              let fileType = res.resultValue.document.fileType
              let id = res.resultValue.document.key
              // let urlList = res.resultValue.document.url
              // let callList = res.resultValue.editConfig.callbackUrl
              let type = res.resultValue.documentType
              $(location).attr("href", "NewBuilt.html?fileType=" + fileType + "&id=" + id + "&type=" + type);
            } else if (res.code == 500) {
              mui.toast(res.resultValue, {
                duration: 1000,
                type: 'div'
              })
            } else {
              mui.toast('失败', {
                duration: 1000,
                type: 'div'
              })
            }
          } else {
            mui.toast('完整性校验失败', {
              duration: 1000,
              type: 'div'
            })
          }
        },
        error: (e) => {
          $(".curtain").css("display", "none");
          mui.toast('请求异常,请稍后再试', {
            duration: 1000,
            type: 'div'
          })
        },
      });
    },
  },
});